package com.yhd;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;


@AllArgsConstructor
@NoArgsConstructor
public class SqlSession {

    private Configuration configuration;

    private Executor executor;


    public <T> T selectOne(String statementId, Object... parameters)throws Exception {
        String sql = Configuration.sqlMappings.getString(statementId);
        if (null != sql && !"".equals(sql)) {
            return executor.query(sql, parameters);
        }
        return null;
    }

    public <T> T getMapper(Class clazz) {
        return (T) configuration.getMapper(clazz, this);
    }


}